package cn.wolfcode.p2p.website.web.controller;

import cn.wolfcode.p2p.base.anno.RequiredLogin;
import cn.wolfcode.p2p.base.domain.LoginInfo;
import cn.wolfcode.p2p.base.service.IAccountService;
import cn.wolfcode.p2p.base.service.IUserInfoService;
import cn.wolfcode.p2p.base.util.LoginInfoContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class PersonalController {

    @Autowired
    private IAccountService accountService;
    @Autowired
    private IUserInfoService userInfoService;

    @RequestMapping("/personal")
    @RequiredLogin
    public String toPersonalPage(Model model){
        // 获取当前登录的session
        LoginInfo currentLoginInfo = LoginInfoContext.getCurrentLoginInfo();

        model.addAttribute("account", accountService.get(currentLoginInfo.getId()));
        model.addAttribute("userInfo", userInfoService.get(currentLoginInfo.getId()));
        return "personal";
    }
}























